package com.ruan.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.CustomExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName:RabbitMQConfig
 * @Author:阮昇
 * @Description:
 * @Datetime: 2023/9/22 15:39
 **/
@Configuration
public class RabbitMQConfig {

    @Bean
    public Queue emailQueue(){
        return new Queue("email-queue");
    }

    @Bean
    public CustomExchange emailExchange() {
        return new CustomExchange("email-exchange", "direct", true, false);
    }

    @Bean
    public Binding emailBinding(Queue emailQueue, CustomExchange emailExchange) {
        return BindingBuilder.bind(emailQueue).to(emailExchange).with("email-routing-key").noargs();
    }

}
